//
//  ViewController.m
//  test
//
//  Created by 谢伟 on 16/3/23.
//  Copyright © 2016年 wei.xie. All rights reserved.
//

#import "ViewController.h"
#import "XWViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    /*
     * 在视图控件中想modal一个控制器，我们可以使用[[UIApplication sharedApplication].keyWindow.rootViewController获得根控制器
     * 之后就可以modal了
     */
    
    UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(40, 200, 200, 44)];
    [btn setTitle:@"点击" forState:UIControlStateNormal];
    btn.backgroundColor = [UIColor blueColor];
    [btn addTarget:self action:@selector(btnClickAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
}

#pragma mark - 按钮点击方法监听
- (void)btnClickAction:(UIButton *)btn {
    XWViewController *vc = [[XWViewController alloc] init];
    [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:vc animated:YES completion:nil];
}

@end
